<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2019/4/7
 * Time: 19:28
 */

namespace common\sources\read\cashrecord;


use common\models\craftsman\CashRecord;

class CashRecordAccess implements ICashRecordAccess
{
    public function getList($data)
    {
        return CashRecord::find()
                ->select("id,serial_num,arrival_money,money,create_time,cash_status,remark,reason")
                ->where(["bus_id" => $data['bus_id']])
                ->orderBy("create_time desc")
                ->offset(($data['page_num'] -1) * $data['limit'])
                ->limit($data['limit'])
                ->asArray()
                ->all();
        // TODO: Implement getCashRecord() method.
    }

    public function getCount($data)
    {
        return CashRecord::find()
                ->where(['bus_id' => $data['bus_id']])
                ->count();
    }

    public function getCashDetail($cash_id)
    {
        return CashRecord::find()
            ->select("id,serial_num,arrival_money,money,create_time,cash_status,remark")
            ->where(["id" => $cash_id])
            ->asArray()
            ->one();
    }

}